package dataswitch

import (
	"strconv"
	"strings"
)

//SwitchString2Int64 转化string 为 int64
//如："20" => 20
func SwitchString2Int64(d string) int64 {
	if i, err := strconv.ParseInt(d, 10, 64); err != nil {
		return 0
	} else {
		return i
	}
}

//SwitchVersion2Int64 转换version 为 int64
//如：v1.4.5  => 145
func SwitchVersion2Int64(d string) int64 {
	d = strings.Replace(strings.ToUpper(d), "V", "", 1)
	d = strings.Replace(d, ".", "", -1)
	return SwitchString2Int64(d)
}
